package com.ibigcat.module.mdm.dao.mapper;

import java.util.*;

import com.ibigcat.framework.common.pojo.PageResult;
import com.ibigcat.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.ibigcat.framework.mybatis.core.mapper.BaseMapperX;
import com.ibigcat.module.mdm.dao.entity.FileDO;
import org.apache.ibatis.annotations.Mapper;
import com.ibigcat.module.mdm.controller.admin.file.vo.*;

/**
 * 文件 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface FileMapper extends BaseMapperX<FileDO> {

    default PageResult<FileDO> selectPage(FilePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<FileDO>()
                .eqIfPresent(FileDO::getSourceId, reqVO.getSourceId())
                .eqIfPresent(FileDO::getSourceType, reqVO.getSourceType())
                .eqIfPresent(FileDO::getFileId, reqVO.getFileId())
                .likeIfPresent(FileDO::getFileName, reqVO.getFileName())
                .eqIfPresent(FileDO::getFilePath, reqVO.getFilePath())
                .eqIfPresent(FileDO::getFileFormat, reqVO.getFileFormat())
                .eqIfPresent(FileDO::getFileSize, reqVO.getFileSize())
                .likeIfPresent(FileDO::getUploaderName, reqVO.getUploaderName())
                .betweenIfPresent(FileDO::getUploadTime, reqVO.getUploadTime())
                .betweenIfPresent(FileDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(FileDO::getId));
    }

}